 <?php
	print("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?> \n");
	print("<KID>\n");
	if(!isset($_GET["name"]) || !isset($_GET["PID"]))
	{
		print("</KID>\n");
		return;
	}
	$db = mysql_connect("localhost","root","root");
    mysql_select_db("brainway");
	$query = "insert into knowledge_name (name, project_id) values (\"".$_GET["name"]."\",\"".$_GET["PID"]."\")";
    $result = mysql_query($query);
    if($result==null)       //name has existed
    {
        print("</KID>\n");
		return;
    }
    
    $query = "select max(KID) KID from knowledge_name";
    $result = mysql_query($query);
    $row = mysql_fetch_array($result);
    print($row["KID"]);
    print("\n</KID>");
?>